package com.gm.wholesale.module.login.jsfunction

import android.webkit.JavascriptInterface
import com.gm.commonlib.util.logUtils.LogUtil
import com.gm.wholesale.module.login.ui.LoginActivity
import com.gm.wholesale.module.user.UserDataManger

class LoginWebViewCallBack(private val mActivity: LoginActivity?) {
    // todo 登录成功后 网页回调
    @JavascriptInterface
    fun loginSuccess(userData: String) {
        LogUtil.d("loginSuccess: $userData")
        UserDataManger.newInstance().saveUserInfo(userData)
        mActivity!!.runOnUiThread {
            if (mActivity != null) {
                mActivity.loginSuccess()
            }
        }
    }
    companion object {
        const val loginViewCallBack = "app"
    }
}